﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BdClient;

namespace Univer
{
    public partial class TransactionsForm : Form
    {
        private readonly BdExecute _execute;
        public TransactionsForm()
        {
            _execute = new BdExecute();
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var table = new DataTable();
            table.Columns.Add("id");
            table.Columns.Add("имя");
            table.Columns.Add("Фамилия");
            table.Columns.Add("Отчество");
            table.Columns.Add("Пасспорт");
            table.Columns.Add("телефон");
            table.Rows.Clear();

            if (radioButton1.Checked)
            {
                foreach (var transaction in _execute.GetTransacation())
                {

                    table.Rows.Add(transaction.FirstName,
                        transaction.Name, transaction.SecondName,
                        transaction.Patronymic, transaction.dateStart, transaction.dateEnd);
                }
            }
            else if (radioButton2.Checked)
            {
                foreach (var transaction in _execute.GetTransacationEnd(DateTime.Now))
                {
                    table.Rows.Add(transaction.FirstName,
                         transaction.Name, transaction.SecondName,
                         transaction.Patronymic, transaction.dateStart, transaction.dateEnd);
                }
            }else if (radioButton3.Checked)
            {
                foreach (var transaction in _execute.GetTransacationActiv(DateTime.Now))
                {
                    table.Rows.Add(transaction.FirstName,
                         transaction.Name, transaction.SecondName,
                         transaction.Patronymic, transaction.dateStart, transaction.dateEnd);
                }
            }
            
            dataGridView1.DataSource = table;
        }
    }
}
